package com.blackcat.annotation.aspect.component;

import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * <p> 描述 : aop通知注解
 * @author : blackcat
 * @date  : 2020/8/3 16:30
*/
@Aspect
@Component
public class UserAspect {
	/**
	 * @Pointcut 定义一个切点，避免重复引用
	 */
	@Pointcut("execution(* com.blackcat.annotation.aspect.component.UserServiceImpl.test(..))")
	public void print(){}

	@Before("print()")
	public void before(){
		System.out.println("我是前置通知");
	}

	@After("print()")
	public void After(){
		System.out.println("我是后置通知");
	}

	@AfterReturning("print()")
	public void AfterReturning(){
		System.out.println("我是返回通知");
	}

	@AfterThrowing("print()")
	public void AfterThrowing(){
		System.out.println("我是异常通知");
	}

}
